##### 定义获取树形结构的方法,递归实现法
def getTree(data,pid=0):

    tree = [] #### 定义一个空的列表数据
    if len(data) <=0:
        return tree

    # for item in data:
    #     item['title']=item['name']
    #     item['key']=item['id']

    for item in data:
        if item['pid'] == pid:
            tmp = getTree(data,item['id'])
            print(tmp)
            item['children'] = tmp
            # item['children']['title'] = tmp['name']

            tree.append(item)
    return tree
